home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: initializeVHG.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:32 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include <stdio.h>
- #include "ess.h"
- #include "checking.h"
- #include "io.h"
- #include "object.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "bf_external_group.h"
- #include "version_graph.h"
- #include "version_funcs.h"
-
-
- int
- initializeVHG(
- VERSIONGRAPH *graph, /* the graph to initialize */
- OID *oid, /* object at root of VHG */
- VHGNODEFLAGS flags /* initial flags for the root node */
- )
- {
- VHGNODEID nodeId;
- VHGNODE *rootNode;
-
- TRPRINT(TR_VERSION, TR_LEVEL_1, ("Initializing VHG\n") );
-
- /*
- * store the initial size of the node array
- */
- graph->nodeCount = VHGINITSIZE;
-
- /*
- * init the header for the list of free nodes
- */
- initializeVHGList(graph, &graph->freeList);
-
- /*
- * Initialize each node and add it to the free list
- */
- for( nodeId = 0; nodeId < VHGINITSIZE; nodeId++) {
- initializeVHGNode(graph, &graph->nodeArray[nodeId], nodeId);
- listVHGEnq(graph, &graph->freeList, &graph->nodeArray[nodeId].siblings);
- }
-
-
- /*
- * Get a root node.
- */
- rootNode = listVHGDeq(graph, &graph->freeList);
- if (rootNode == NULL) {
- SM_ERROR(TYPE_WARNING, esmINTERNAL);
- return(NULL);
- }
-
-
- /*
- * Check its magic number
- */
- CHECK_VHGNODE_MAGIC(rootNode);
-
- /*
- * Set up the root node id and the oid for the object it represents
- */
- graph->root = rootNode->id;
- rootNode->oid = *oid;
-
- /*
- * the root has no parent
- */
- rootNode->parentId = VHGNULLNODE;
-
- /*
- * the root initially has no children
- */
- initializeVHGList(graph, &rootNode->children);
-
- /*
- * the root has no siblings except itself
- */
- initializeVHGListElement(&rootNode->siblings, VHGOFFSET(graph, rootNode));
-
- /*
- * Initialize the flags for the root node
- */
- rootNode->flags = flags;
-
- /*
- * Set up the graph's magic number
- */
- INIT_VERSIONGRAPH_MAGIC(graph);
-
- return(esmNOERROR);
- }
-